package com.junglone.gateway.admin.service;

import org.springframework.cloud.gateway.event.RefreshRoutesEvent;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.stereotype.Service;

/**
 * Description: 路由事件服务(监听,增删改后重新加载路由配置)
 * 
 * @author junglone: <a href="mailto:cjlnzb@hotmail.com">cjlnzb@hotmail.com</a>
 * @since 2021/04/04 00:21
 */
@Service
class MongoRouteEventService implements ApplicationEventPublisherAware {

	private ApplicationEventPublisher applicationEventPublisher;

	@Override
	public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {

		this.applicationEventPublisher = applicationEventPublisher;
	}

	void notifyChanged() {

		this.applicationEventPublisher.publishEvent(new RefreshRoutesEvent(this));
	}

}
